﻿using System.Collections.ObjectModel;

namespace Central.Linq.MvcJson.Engine {

	public class InfoHelper {

		private InfoHelper() { }

		/// <summary>
		/// Возвращает коллекцию возможных операторов для фильтрации через PrepareQuery
		/// </summary>
		/// <param name="type">1) string; 2) bool; 3) enum; остальные = 0</param>
		/// <returns></returns>
		public static Collection<OperatorName> ApplicableFilterOperators(int type) {
			Collection<OperatorName> filterOperators = new Collection<OperatorName>();
			if (type == 1) { //string
				filterOperators.Add(new OperatorName() { Name = "Contains", DisplayName = "содержит" });
				filterOperators.Add(new OperatorName() { Name = "DoesNotContain", DisplayName = "не содержит" });
				filterOperators.Add(new OperatorName() { Name = "StartsWith", DisplayName = "начинается на" });
				filterOperators.Add(new OperatorName() { Name = "DoesNotStartsWith", DisplayName = "не начинается на" });
				filterOperators.Add(new OperatorName() { Name = "EndsWith", DisplayName = "заканчивается на" });
				filterOperators.Add(new OperatorName() { Name = "DoesNotEndsWith", DisplayName = "не заканчивается на" });
				filterOperators.Add(new OperatorName() { Name = "IsNull", DisplayName = "пусто" });
				filterOperators.Add(new OperatorName() { Name = "IsNotNull", DisplayName = "не пусто" });
				filterOperators.Add(new OperatorName() { Name = "IsEqualTo", DisplayName = "равно" });
				filterOperators.Add(new OperatorName() { Name = "IsNotEqualTo", DisplayName = "не равно" });
				filterOperators.Add(new OperatorName() { Name = "IsGreaterThan", DisplayName = "больше" });
				filterOperators.Add(new OperatorName() { Name = "IsGreaterThanOrEqualTo", DisplayName = "больше или равно" });
				filterOperators.Add(new OperatorName() { Name = "IsLessThan", DisplayName = "меньше" });
				filterOperators.Add(new OperatorName() { Name = "IsLessThanOrEqualTo", DisplayName = "меньше или равно" });
			}
			else if (type == 2 || type == 3) { // bool enum
				filterOperators.Add(new OperatorName() { Name = "IsEqualTo", DisplayName = "равно" });
				filterOperators.Add(new OperatorName() { Name = "IsNotEqualTo", DisplayName = "не равно" });
			}
			else { // data number
				filterOperators.Add(new OperatorName() { Name = "IsNull", DisplayName = "пусто" });
				filterOperators.Add(new OperatorName() { Name = "IsNotNull", DisplayName = "не пусто" });
				filterOperators.Add(new OperatorName() { Name = "IsEqualTo", DisplayName = "равно" });
				filterOperators.Add(new OperatorName() { Name = "IsNotEqualTo", DisplayName = "не равно" });
				filterOperators.Add(new OperatorName() { Name = "IsGreaterThan", DisplayName = "больше" });
				filterOperators.Add(new OperatorName() { Name = "IsGreaterThanOrEqualTo", DisplayName = "больше или равно" });
				filterOperators.Add(new OperatorName() { Name = "IsLessThan", DisplayName = "меньше" });
				filterOperators.Add(new OperatorName() { Name = "IsLessThanOrEqualTo", DisplayName = "меньше или равно" });
			}
			return filterOperators;
		}
	}
}